

#if !defined bookplayheadfile 
#define bookplayheadfile 

void bookplay(int type); 
void bkchange(int tnplc,int*freq,int*plc,int*time); 


void bkchange(int tnplc,int*freq,int*plc,int*time) 
{ 
char key[]={'z','x','c','v','b','n','m', 
'a','s','d','f','g','h','j', 
'q','w','e','r','t','y','u'}; 
int num=notes[tnplc-1].num; 
if(num==0||num==-1)*freq=0; 
else if(num==8) 
{ 
*time=fullnote; 
return; 
} 
else if(num!=8&&num!=0&&num!=-1) 
{ 
change(key[num%10-1+(num/10)*7],freq,plc); 
switch(notes[tnplc-1].length) 
{ 
case '=':*time=fullnote/4;break; 
case '-':*time=fullnote/2;break; 
case '>':*time=3*fullnote/4;break; 
case '.':*time=3*fullnote/2;break; 
case ' ':*time=fullnote;break; 
default:break; 
} 
} 
} 
void bookplay(int type) 
{ 
int freq=0,plc=-1,time=0,n,t; 
for(t=0;t<N;t++) 
{ 
if(notes[t].num!=8) 
{ 
nosound(); 
if(type)keyup(plc); 
} 
bkchange(t+1,&freq,&plc,&time); 
if(freq!=0) 
{ 
sound(freq); 
if(type)keydn(plc); 
} 
for(n=0;n<time;n++) 
{ 
if(kbhit()) 
{ 
nosound(); 
return; 
} 
delay(100); 
} 
} 
nosound(); 
if(type)keyup(plc); 
} 


#endif 

/*end of bookplay.h*/ 